package com.bw.module_service.fragment

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.lib_common.arouter.Router
import com.bw.lib_common.base.BaseFragment
import com.bw.module_service.R
import com.bw.module_service.adapter.GetSignInfoAdapter
import com.bw.module_service.databinding.FragmentLateBinding
import com.bw.module_service.viewmodel.ServiceViewModel


class LateFragment : BaseFragment<ServiceViewModel,FragmentLateBinding>() {
    override val mLayoutResId: Int
        get() = R.layout.fragment_late

    private val mViewModel: ServiceViewModel by activityViewModels()

    private lateinit var mAdapter: GetSignInfoAdapter

    override fun initView() {
        super.initView()

    }

    override fun initData() {
        mViewModel.getSignInfo(1)
    }

    override fun initListener() {
        mViewModel.signInfoLiveData_.observe(this){
            val normalList = it.filter { it.status == "迟到" }
            mAdapter = GetSignInfoAdapter(normalList,onItemCLick = {
                ARouter.getInstance().build(Router.Ui.AttendancesActivity).navigation()
                Log.d("aaa",  "model:00000)")
            })
            mBinding.rvSign.adapter = mAdapter
            mBinding.rvSign.layoutManager = LinearLayoutManager(requireContext())
            mAdapter.notifyDataSetChanged()
        }
    }

}